project ( mpack C CXX)
cmake_minimum_required ( VERSION 2.8 )

include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/mpack)

aux_source_directory(${PROJECT_SOURCE_DIR}/src/mpack mpack_source)
aux_source_directory(${PROJECT_SOURCE_DIR}/test test_source)

set(CMAKE_C_FLAGS -std=c99)

INCLUDE_DIRECTORIES(test)

add_library(mpack STATIC ${mpack_source})
add_library(mpack_so SHARED ${mpack_source})
set_target_properties(mpack PROPERTIES FOLDER "libs")
set_target_properties(mpack_so PROPERTIES FOLDER "libs")
set_target_properties(mpack_so PROPERTIES OUTPUT_NAME "mpack")

add_definitions(-DTEST_PATH="${PROJECT_SOURCE_DIR}/test/")
add_executable(mpack_test ${test_source})
target_link_libraries(mpack_test mpack)

enable_testing()
add_test(test_mpack ${PROJECT_BINARY_DIR}/mpack_test)

if (CMAKE_GENERATOR MATCHES "Visual Studio")
  set_target_properties(mpack
  PROPERTIES COMPILE_FLAGS "/TP")
endif ()
